#include <scrollingdialog.h>
#include <manager.h>
#include <configmanager.h>
#include <pluginmanager.h>
#include <M_Code_plugin.h>
#include <globals.h>

class BatchLogWindow : public wxScrollingDialog {
  public:
    BatchLogWindow( wxWindow *parent, const wxChar *title )
      : wxScrollingDialog( parent, -1, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX | wxMINIMIZE_BOX ) {
      wxSize size;
      size.SetWidth( Manager::Get()->GetConfigManager( _T( "message_manager" ) )->ReadInt( _T( "/batch_build_log/width" ), wxDefaultSize.GetWidth() ) );
      size.SetHeight( Manager::Get()->GetConfigManager( _T( "message_manager" ) )->ReadInt( _T( "/batch_build_log/height" ), wxDefaultSize.GetHeight() ) );
      SetSize( size );
    }
    void EndModal( int retCode ) {
      bool hasRunning = cbHasRunningCompilers( Manager::Get()->GetPluginManager() );
      if( hasRunning ) {
        if( msging( _T( "正在生成.确定要中止它吗?" ), _T( "中止生成?" ), wxICON_QUESTION | wxYES_NO, this ) == wxID_YES ) {
          cbStopRunningCompilers( Manager::Get()->GetPluginManager() );
          return;
        }
      }
      Manager::Get()->GetConfigManager( _T( "message_manager" ) )->Write( _T( "/batch_build_log/width" ), ( int )GetSize().GetWidth() );
      Manager::Get()->GetConfigManager( _T( "message_manager" ) )->Write( _T( "/batch_build_log/height" ), ( int )GetSize().GetHeight() );
      wxScrollingDialog::EndModal( retCode );
    }
};
